<%@include file="/page/tag.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>企业办公管理系统</title>


<link href="${ctp}/QUI/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link href="${ctp}/QUI/libs/skins/lightBlue/style.css" rel="stylesheet" type="text/css" id="theme" themeColor="lightBlue"/>

<link href="${ctp}/QUI/login_skin/style.css" rel="stylesheet" type="text/css" id="skin"/>
<script type="text/javascript" src="${ctp}/QUI/libs/js/jquery.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/language/cn.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/main.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/login.js"></script>
<!--弹窗组件start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/popup/drag.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/popup/dialog.js"></script>
<!--弹窗组件end-->
<!--居中显示start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/method/center-plugin.js"></script>
<!--居中显示end-->
<style>
/*提示信息*/	
#cursorMessageDiv {
	position: absolute;
	z-index: 99999;
	border: solid 1px #cc9933;
	background: #ffffcc;
	padding: 2px;
	margin: 0px;
	display: none;
	line-height:150%;
}
/*提示信息*/
.white{
	color:#ffffff;
}
.white a{
	color:#ffffff;
	text-decoration:underline;
}
.white a:hover{
	color:#ffffff;
	text-decoration:underline;
}
</style>
</head>
<body >
	<div class="login_main">
		<div class="login_top">
		</div>
		<div class="login_middle">
			<div class="login_middleleft"></div>
			<div class="login_middlecenter">
					<form id="loginForm"  class="login_form" method="post">
					<div class="login_user"><input type="text" id="username"/></div>
					<div class="login_pass"><input type="password" id="password"/></div>
					
					<div style="margin-top: 10px;">
						<span style="display: inline-block;"><input type="checkbox" name="if_save_pwd" id="if_save_pwd"/>记住密码</span>
						<span style="display: inline-block;     margin-left: 20px;"><a href="#" onClick="javascript:top.Dialog.open({URL:'${ctp}/login/change_pwd.html',Title:'更改密码',Modal:false,Width:500,Height:250});"
                           style="cursor:pointer;color:orange;text-decoration:none;">更改密码</a></span>
                           
					</div>
					
					<div class="clear"></div>
					<div class="login_button">
						<div class="login_button_left"><input type="button" onclick="login()"/></div>
						<div class="login_button_right"><input type="reset" value=""/>
						</div>
						<div class="clear"></div>
					</div>
					</form>
					<div class="login_info"  style="display:none;">
					</div>
					<!-- style="display:none;" -->
					
			</div>
			<div class="login_middleright"></div>
			<div class="clear"></div>
		</div>
		<div class="login_bottom">
			<div class="login_copyright">
			<!-- 星期三 --><br/><br/>
			</div>
		</div>
	</div>
<script>
	$(function(){
		var isSave = getCookie('isSave');
		if(isSave){
			document.getElementById("username").value=getCookie('username');
			document.getElementById("password").value=getCookie('password');
			$("#if_save_pwd").attr("checked", "checked");
		}
		
		//居中
		 $('.login_main').center();
		 document.getElementById("username").focus();
		 $("#username").keydown(function(event){
		 	if(event.keyCode==13){
				login()
			}
		 })
		 $("#password").keydown(function(event){
		 	if(event.keyCode==13){
				login()
			}
		 })
		 
	})

	//登录
	function login() {
		var errorMsg = "";
		var loginName = document.getElementById("username");
		var password = document.getElementById("password");
		if(!loginName.value){
			errorMsg += "&nbsp;&nbsp;用户名不能为空!";
		}
		if(!password.value){
			errorMsg += "&nbsp;&nbsp;密码不能为空!";
		}

		if(errorMsg != ""){
			$(".login_info").html(errorMsg);
			$(".login_info").show();
		}
		else{
			$(".login_info").show();
			$(".login_info").html("&nbsp;&nbsp;正在登录中...");
			
			
            if (document.getElementById("if_save_pwd").checked){
            	SetCookie("isSave",true);
            	SetCookie("username",loginName.value);
            	SetCookie("password",password.value);
            }else {
            	delCookie("username");
            	delCookie("password");
            	delCookie("isSave");
            }
            
			//登录处理
			$.post("${ctp}/login/login.do",
				  {"account":loginName.value,"pwd":password.value},
				  function(result){
					  if(result.result){
						  $(".login_info").html("&nbsp;&nbsp;登录成功，正在转到主页...");
						  window.location.href="${ctp }/"+result.url;
					  } else{
						  $(".login_info").html("&nbsp;&nbsp;登陆失败！" + result.msg);
						  return false;
					  }
					  
				  },"json");
		}
	}
	
//写cookies函数
//两个参数，一个是cookie的名子，一个是值
function SetCookie(name,value) {
	    var Days = 30; //此 cookie 将被保存 30 天
	    var exp  = new Date();    //new Date("December 31, 9998");
	    exp.setTime(exp.getTime() + Days*24*60*60*1000);
	    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//取cookies函数
function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return "";
}

//删除cookie
function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
</script>
</body>
</html>

